using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Application.DTOs;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 主题应用服务接口
    /// 提供网站主题管理的业务逻辑
    /// </summary>
    public interface IThemeAppService
    {
        /// <summary>
        /// 获取分页的主题列表
        /// </summary>
        /// <param name="query">查询参数</param>
        /// <returns>分页的主题列表</returns>
        Task<PagedResultDto<ThemeDto>> GetPagedListAsync(PagedQueryDto query);
        
        /// <summary>
        /// 获取所有可用主题
        /// </summary>
        /// <returns>主题列表</returns>
        Task<List<ThemeDto>> GetAvailableThemesAsync();
        
        /// <summary>
        /// 根据ID获取主题详情
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>主题详情</returns>
        Task<ThemeDto?> GetByIdAsync(long id);
        
        /// <summary>
        /// 根据名称获取主题
        /// </summary>
        /// <param name="name">主题名称</param>
        /// <returns>主题信息</returns>
        Task<ThemeDto?> GetByNameAsync(string name);
        
        /// <summary>
        /// 获取当前激活的主题
        /// </summary>
        /// <returns>当前主题</returns>
        Task<ThemeDto?> GetActiveThemeAsync();
        
        /// <summary>
        /// 获取默认主题
        /// </summary>
        /// <returns>默认主题</returns>
        Task<ThemeDto?> GetDefaultThemeAsync();
        
        /// <summary>
        /// 创建主题
        /// </summary>
        /// <param name="dto">主题数据</param>
        /// <returns>创建的主题</returns>
        Task<ThemeDto> CreateAsync(ThemeDto dto);
        
        /// <summary>
        /// 更新主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <param name="dto">更新的主题数据</param>
        /// <returns>更新后的主题</returns>
        Task<ThemeDto> UpdateAsync(long id, ThemeDto dto);
        
        /// <summary>
        /// 删除主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteAsync(long id);
        
        /// <summary>
        /// 批量删除主题
        /// </summary>
        /// <param name="ids">主题ID列表</param>
        /// <returns>删除结果</returns>
        Task<bool> BatchDeleteAsync(List<long> ids);
        
        /// <summary>
        /// 安装主题
        /// </summary>
        /// <param name="themePackage">主题包</param>
        /// <returns>安装结果</returns>
        Task<ThemeDto> InstallAsync(byte[] themePackage);
        
        /// <summary>
        /// 卸载主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>卸载结果</returns>
        Task<bool> UninstallAsync(long id);
        
        /// <summary>
        /// 激活主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>激活结果</returns>
        Task<bool> ActivateAsync(long id);
        
        /// <summary>
        /// 停用主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>停用结果</returns>
        Task<bool> DeactivateAsync(long id);
        
        /// <summary>
        /// 设置默认主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>设置结果</returns>
        Task<bool> SetDefaultAsync(long id);
        
        /// <summary>
        /// 启用/禁用主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <param name="enabled">是否启用</param>
        /// <returns>操作结果</returns>
        Task<bool> SetEnabledAsync(long id, bool enabled);
        
        /// <summary>
        /// 复制主题
        /// </summary>
        /// <param name="id">原主题ID</param>
        /// <param name="newName">新主题名称</param>
        /// <returns>复制的主题</returns>
        Task<ThemeDto> CopyAsync(long id, string newName);
        
        /// <summary>
        /// 导出主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>主题包数据</returns>
        Task<byte[]> ExportAsync(long id);
        
        /// <summary>
        /// 预览主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>预览URL</returns>
        Task<string> PreviewAsync(long id);
        
        /// <summary>
        /// 获取主题配置
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>主题配置</returns>
        Task<Dictionary<string, object>> GetConfigurationAsync(long id);
        
        /// <summary>
        /// 更新主题配置
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <param name="configuration">配置数据</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateConfigurationAsync(long id, Dictionary<string, object> configuration);
        
        /// <summary>
        /// 重置主题配置
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>重置结果</returns>
        Task<bool> ResetConfigurationAsync(long id);
        
        /// <summary>
        /// 检查主题兼容性
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>兼容性结果</returns>
        Task<(bool IsCompatible, string[] Issues)> CheckCompatibilityAsync(long id);
        
        /// <summary>
        /// 更新使用次数
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>更新结果</returns>
        Task<bool> IncrementUsageCountAsync(long id);
        
        /// <summary>
        /// 获取主题统计信息
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>统计信息</returns>
        Task<Dictionary<string, object>> GetStatisticsAsync(long id);
        
        /// <summary>
        /// 验证主题
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>验证结果</returns>
        Task<(bool IsValid, string[] Errors)> ValidateAsync(long id);
        
        /// <summary>
        /// 检查主题名称是否存在
        /// </summary>
        /// <param name="name">主题名称</param>
        /// <param name="excludeId">排除的主题ID</param>
        /// <returns>是否存在</returns>
        Task<bool> ExistsAsync(string name, long? excludeId = null);
        
        /// <summary>
        /// 搜索主题
        /// </summary>
        /// <param name="keyword">搜索关键字</param>
        /// <param name="features">特性过滤</param>
        /// <returns>搜索结果</returns>
        Task<List<ThemeDto>> SearchAsync(string keyword, string[]? features = null);
    }
}
